const path = require('path')

function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  publicPath: process.env.NODE_ENV === 'production' ? '/' : '/',
  lintOnSave: false,
  runtimeCompiler: true,
  productionSourceMap: true,
  assetsDir: 'static',
  chainWebpack: config => {
    config.resolve.alias
      .set('@common', resolve('src/common'))
      .set('@assets', resolve('src/assets'))
      .set('@components', resolve('src/components'))
      .set('@views', resolve('src/views'))
      .set('@api', resolve('src/api'))
  },
  configureWebpack: config => {
    config.entry.app = ["babel-polyfill", "./src/main.js"];
  },
  devServer: {
    open: true,
    hot: true,
    port: 8080,
    proxy: {
      '/api': {
        // target: 'http://www.91mydoor.net',// 生产
        target: 'http://zy.91mydoor.com',// 生产
        // target: 'http://123.56.135.191:8099',// 测试 http://123.56.135.191:8099/mendao/login
        ws: false,
        changeOrigin: true,
        pathRewrite: { "^/api": "" }
      }
    }
  }
}
